(function() {
	Path.on("/__basename__.html", function(_current_location) {
		var queryString = _current_location.query;
		get_goods_type = queryString.get("id");
		App.set("$Cahce.goods_list.type", get_goods_type);
		if (get_goods_type == 2) {
			console.log("热销商品")
			App.set("$Cache.goods_list.typename", "热销商品");
			goods_list_url = appConfig.goods.quality_list;
		} else if (get_goods_type == 3) {
			console.log("商品列表")
			App.set("$Cache.goods_list.typename", "商品列表");
			var goods_list_url = appConfig.goods.list;
		} else {
			console.log("商品分类")
			App.set("$Cache.goods_list.typename", "商品分类");
			var goods_list_url = appConfig.goods.list;
		}

		//页号
		var current_page_num = ~~queryString.get("page");
		console.log(current_page_num);
		//每页显示数量
		var goods_pre_num = 16;
		App.set("$Cache.goods_list.goods_pre_num", goods_pre_num);
		jSouper.ready(function(argument) {
			App.set("$Cache.goods_list.current_page_num", current_page_num);
		});
		//获取指定页的商品
		coAjax.get(goods_list_url, {
			bus_id: busInfo._id,
			num: goods_pre_num,
			page: current_page_num
		}, function(result) {
			jSouper.ready(function() {
				console.log(result)
				App.set("$Cache.goods_list.goods", result.result);
			});
		});
		//获取所有商品数量
		coAjax.get(appConfig.goods.number, {
			bus_id: busInfo._id,
		}, function(result) {
			jSouper.ready(function() {
				var number = ~~result.result
				App.set("$Cache.goods_list.goods_number", number);
				var _goods_number_list = [];
				_goods_number_list.length = number;
				var _page_num = [];
				//向上取整获取页数
				_page_num.length = Math.ceil(number / goods_pre_num);
				App.set("$Cache.goods_list.goods_number_list", _goods_number_list);
				App.set("$Cache.goods_list.page_num", _page_num);
			});
		});
	});
	//------------

	
}());